namespace PHMEE.PHM.Algorithms.Basic;

/// <summary>
/// 加速度积分算法
/// </summary>
public sealed class AccToVelAlg
{
    private readonly AccToVelService.AccToVelServiceClient _client;

    public AccToVelAlg(AccToVelService.AccToVelServiceClient client)
    {
        _client = client;
    }

    /// <summary>
    /// 加速度积分算法
    /// </summary>
    /// <param name="accData">加速度 振动信号时域序列</param>
    /// <param name="sampleRate">采样频率</param>
    /// <param name="filterFreq">截止频率 高通截至频率，默认10Hz</param>
    /// <returns></returns>
    public AccToVelResponse AccToVel(float[] accData, float sampleRate, float filterFreq)
    {
        var request = new AccToVelRequest
        {
            AccData = { accData },
            SampleRate = sampleRate,
            FilterFreq = filterFreq
        };

        return _client.AccToVelAlg(request);
    }

    /// <summary>
    /// 加速度积分算法
    /// </summary>
    /// <param name="accData">加速度 振动信号时域序列</param>
    /// <param name="sampleRate">采样频率</param>
    /// <param name="filterFreq">截止频率 高通截至频率，默认10Hz</param>
    /// <returns></returns>
    public async Task<AccToVelResponse> AccToVelAsync(float[] accData, float sampleRate, float filterFreq = 10)
    {
        var request = new AccToVelRequest
        {
            AccData = { accData },
            SampleRate = sampleRate,
            FilterFreq = filterFreq
        };

        return await _client.AccToVelAlgAsync(request);
    }
}